package view.manager
{
	import flash.display.Stage;
	
	import mx.core.UIComponent;

	/**
	 * 右下角Tip管理器
	 **/
	public class RBTipManager
	{
		private static var OFFSET : Number = 30;
		private static var inst : RBTipManager;
		
		private var stagePanel : Object;
		private var uiTarget : UIComponent;
		
		public function RBTipManager()
		{
			
		}
		
		public static function getInst():RBTipManager
		{
//			if ( inst == null )
//			{
				inst = new RBTipManager();
//			}
			return inst;
		}
		
		/**
		 * 设置视图
		 **/
		public function setView( stagePanel:Object=null, uiTarget:UIComponent=null):void
		{
			if ( stagePanel != null && uiTarget != null )
			{
				this.stagePanel = stagePanel;
				this.uiTarget = uiTarget;
			}
			else
			{
				throw new Error("不能传入一个空的视图.");				
			}
		}
		
		public function updateRBPosition():void
		{
			uiTarget.left = this.stagePanel.stageWidth - uiTarget.width - OFFSET;
			uiTarget.top = this.stagePanel.stageHeight - uiTarget.height - OFFSET;
		}
		
		/*更新左下角控制图标*/
		public function updateLBPosition():void
		{
			uiTarget.left = OFFSET;
			uiTarget.top = this.stagePanel.stageHeight - uiTarget.height - OFFSET;			
		}
		
		/**
		 *  右上角
		 **/
		public function updateTRPostion():void
		{
			uiTarget.left = this.stagePanel.stageWidth - uiTarget.width - OFFSET;
			uiTarget.top = this.stagePanel.stageHeight - uiTarget.height - OFFSET;
		}
		
		/**
		 * 放到Resize事件中
		 **/
		public function onResizeHandler():void
		{
			updateRBPosition();	
		}
	}
}